<template>
  <div class="app-container">

    <SearchContent :queryParams="queryParams" @query="handleQuery" @reset="resetQuery">

      <el-col :span="6">
        <el-form-item label="组织名称:" prop="orgName">
          <el-input v-model="queryParams.orgName" clearable placeholder="请输入组织名称"></el-input>
        </el-form-item>
      </el-col>

    </SearchContent>

    <div class="card-wrap paddingAll20">
<!--      <div class="table-title-wrap justify-end">-->
<!--        <el-button type="primary" size="mini" @click="handleUpdate"-->
<!--                   v-hasPermi="['ncInfo:vatRate:update']">更新-->
<!--        </el-button>-->
<!--      </div>-->


      <table-page :loading="loading" :dataList="dataList" :total="total" :page.sync="queryParams.pageNum"
                  :limit.sync="queryParams.pageSize" @setSizeCurrent="getList" border>
        <template slot="tableColAc">
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100px">
            <template v-slot="{row}">
              <e-button v-hasPermi="['ncInfo:vatRate:delete']" size="mini" type="text" @click="deleteRow(row)"
              >作废
              </e-button>
            </template>
          </el-table-column>
        </template>
        <template slot="tableCol">
          <el-table-column label="组织名称" align="center" prop="orgName" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="NC编码" align="center" prop="dataFormat" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="NCid" align="center" prop="dataNum" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="增值税率ID" align="center" prop="vatRateId" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="税码" align="center" prop="vatRateCode" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="收税国家" align="center" prop="associatedCustomer" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="描述" align="center" prop="description" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="购销类型" align="center" prop="createTime" min-width="120px" show-overflow-tooltip>
            <template v-slot="{row}">
              <dict-tag :options="dict.type.nc_purchasesale_type" :value="row.pursaleType"/>
            </template>
          </el-table-column>
          <el-table-column label="物料税率编码" align="center" prop="mattaxesCode" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="物料税率名称" align="center" prop="mattaxesName" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="供应商税率编码" align="center" prop="suptaxesCode" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="供应商税率名称" align="center" prop="suptaxesName" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="客户税率编码" align="center" prop="custaxesCode" min-width="120px" show-overflow-tooltip/>
          <el-table-column label="客户税率名称" align="center" prop="custaxesName" min-width="120px" show-overflow-tooltip/>
        </template>
      </table-page>
    </div>
    <!--    <AddVatRate ref="addvatRate"></AddVatRate>-->
  </div>
</template>

<script>
import SearchContent from "@/components/SearchContent/index.vue";
import AddVatRate from "@/views/system/ncInfo/components/vatRate/AddVatRate.vue";
import * as ncApi from "@/api/system/nc";


export default {
  name: "VatRateList",
  components: {
    SearchContent,
    AddVatRate
  },
  dicts: ['nc_purchasesale_type'],
  data() {
    return {
      // 遮罩层
      loading: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orgName: null,
      },
      total: 0,
      dataList: []

    };
  },
  mounted() {
    this.getList()
  },
  methods: {
    /** 查询测试单表列表 */
    getList() {
      this.loading = true;
      ncApi.vatRateList(this.queryParams).then(res => {
        this.dataList = res.rows;
        this.total = res.total;
      }).finally(() => {
        this.loading = false
      })

    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.$nextTick(() => {
        this.$refs?.queryForm?.resetFields();
        this.handleQuery();
      })
    },
    //更新
    handleUpdate() {
      ncApi.synchronousVatRateList().then(res => {
        this.handleQuery()
      })
    },
    //作废
    deleteRow(row) {
      this.$confirm('此操作将作废该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        ncApi.vatRateDelete(row.id).then(res => {
          this.handleQuery()
          this.$message.success('作废成功')
        })
      })
    }

  }
};
</script>
